import Vue from 'vue'
import VueRouter from 'vue-router'
import IndexView from '../views/IndexView.vue'
import DisplayView from '../views/DisplayView.vue'
import ManageView from '../views/ManageView.vue'
import UserManageView from '../views/UserManageView.vue'
import WindowsSettingView from '../views/WindowsSettingView.vue'
import ContentSetting from '../views/ContentSetting.vue'
import SystemSetting from '../views/SystemSetting.vue'
import BackgroundStyle from '../views/BackgroundStyle.vue'
import PersonImage from '../views/PersonImage.vue'
import FontStyle from '../views/FontStyle.vue'
import ShootingSetting from '../views/ShootingSetting.vue'
import FaceRecognition from '../views/FaceRecognition.vue'
Vue.use(VueRouter)

const originalPush = VueRouter.prototype.push
//修改原型对象中的push方法
VueRouter.prototype.push = function push(location) {
  return originalPush.call(this, location).catch(err => err)
}
//解决vue路由重复导航错误
//获取原型对象上的push函数

const routes = [
  {
    path: '/',
    name: 'index',
    component: IndexView
  },
  {
    path: '/display',
    name: 'display',
    component: DisplayView
  },
  {
    path: '/manage',
    name: 'manage',
    component: ManageView,
    children:[
      {
        path:'/',
        redirect:"/UserManage"
      },
      {
        path: "/UserManage",
        name: "UserManage",
        component: UserManageView
      },
      {
        path: "/WindowsSetting",
        name:"windowsSetting",
        component:WindowsSettingView
      },
      {
        path:"/ContentSetting",
        name:"contentSetting",
        component:ContentSetting,
        children:[
          {
            path:'/',
            redirect:'/ContentSetting/PersonImage'
          },
          {
            path:'BackgroundStyle',
            name:'BackgroundStyle',
            component:BackgroundStyle
          },
          {
            path:'PersonImage',
            name:'PersonImage',
            component:PersonImage
          },
          {
            path:'FontStyle',
            name:'FontStyle',
            component:FontStyle
          }
        ]
      },
      {
        path:"/SystemSetting",
        name:"systemSetting",
        component:SystemSetting,
        children:[
          {
            path:'/',
            redirect:'/SystemSetting/ShootingSetting'
          },
          {
            path:'ShootingSetting',
            name:'ShootingSetting',
            component:ShootingSetting
          },
          {
            path:'FaceRecognition',
            name:'FaceRecognition',
            component:FaceRecognition
          }
        ]
      }
    ]
  }
]

const router = new VueRouter({
  routes
})

export default router
